<template>
    <el-date-picker
      v-model="state.value1"
      type="daterange"
      range-separator="至"
      clearable
      @change="dateChange"
      start-placeholder="开始日期"
      end-placeholder="结束日期"
      :default-value="[]"
    >
    </el-date-picker>
</template>
<script>
import { reactive } from "vue";
export default {
  components: {},
  props: {
    value:{
      type:Array
    }
  },
  setup(props, { emit }) {
    console.log(props);
    let state = reactive({
      value1: "",
      obj: {
        begin_date: "",
        end_date: ""
      },
    });
    // 时间改变
    function dateChange(e) {
        if (e != null) {
          state.obj.begin_date = dayjs(e[0]).format("YYYY-MM-DD");
          state.obj.end_date = dayjs(e[1]).format("YYYY-MM-DD");
        }else{
          state.obj.begin_date = "";
          state.obj.end_date = "";
        }
      emit("dateFun", state.obj);
    }
    return {
      state,
      dateChange,
    };
  },
};
</script>
<style lang="scss" scoped>
</style>